home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Sound / LAME / WarpOS / src / HACKING < prev    next >
Encoding:
Text File  |  2001-06-12  |  3.4 KB  |  141 lines

  1. First, see the file STYLEGUIDE
  2.  
  3. ************************************************************************
  4. TESTING
  5. =======
  6. If you make changes, please test.  There is a python
  7. script in the test/ directory which will compare two versions
  8. of lame using a bunch of CBR and ABR options. To run this
  9. script, copy your favorite (and short!) wav file to the
  10. lame/test directory, and run:
  11.  
  12. % cd lame/test
  13. % ./lametest.py [-w]  CBRABR.op castanets.wav lame_orig lame_new
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. ************************************************************************
  21. LAME API
  22.  
  23. For a general outline of the code, see the file API.  
  24. Also, frontend/main.c is a simple front end to libmp3lame.a
  25.  
  26. The guts of the code are called from lame_encode_buffer().
  27.  
  28. lame_encode_buffer() handles buffering and resampling, and
  29. then calls lame_encode_frame() for each frame.  lame_encode_frame()
  30. looks like this:
  31.  
  32. lame_encode_frame_mp3():
  33.    l3psycho_anal()        compute masking thresholds
  34.    mdct_sub()             compute MDCT coefficients
  35.    iteration_loop()       choose scalefactors (via iteration)
  36.                           which determine noise shapping, and 
  37.                           choose best huffman tables for lossless compression
  38.  
  39.    format_bitstream       format the bitstream.  when data+headers are complete,
  40.                           output to internal bit buffer.
  41.    copy_buffer()          copy internal bit buffer into user's mp3 buffer
  42.  
  43. ************************************************************************
  44. ADDING NEW OPTIONS
  45.  
  46. control variable goes in lame_global_flags sturct.
  47. Assume the variable is called 'new_variable'.
  48.  
  49. You also need to write (in get_set.c):
  50.  
  51. lame_set_new_variable()
  52. lame_get_new_variable()
  53.  
  54. And then document the variable in the file USAGE
  55.  
  56. And add a "--option" style command line option to enable this variable
  57. in parse.m
  58.  
  59.  
  60.  
  61. ************************************************************************
  62.  
  63. THREADSAFE:
  64.  
  65. Lame is supposed to be threadsafe.  But it is not yet.
  66.  
  67. Some static variables in takehiro.c need to be moved
  68. into lame_internal_flags (in util.h).  
  69.  
  70.  
  71.  
  72. ************************************************************************
  73. Global Variables:
  74.  
  75. There are two types of global variables.  All data in
  76. both strucs is initialized to zero.
  77.  
  78. 1. lame_global_flags *gfp
  79.  
  80. These are input paramters which are set by the calling program,
  81. and some information which the calling program may be interested in.
  82.  
  83. This struct instantiated by the call to lame_init().  
  84.  
  85.  
  86. 2. lame_internal_flags *gfc
  87.  
  88. Most global variables go here.
  89.  
  90. All internal data not set by the user.  All 'static' data from
  91. old non-reentrant code should be moved here.
  92.  
  93. Defined in util.h.  Data for which the size is known
  94. in advace should be explicitly declaired (for example,
  95. float xr[576]);  Data which needs to be malloc'd is
  96. handled by:  
  97.  
  98. 1.  in lame_init_params(), malloc the data
  99. 2.  be sure to free the data in freegfc()
  100.  
  101.  
  102. If the data to be malloc'd is large and only used in
  103. certain conditions (like resampling), use the following:  
  104. this has the disadvantage that it is hard to catch and return error
  105. flags all the way back up the call stack.
  106.  
  107. 1. Add an initialization variable to the gfc struct: lame_init_resample
  108. 2. In the resample routine, there should be some code like this:
  109.  
  110.    if (0==gfc->lame_init_resample) {
  111.        gfc->lame_init_resample=1;
  112.       /* initialization code: malloc() data, etc */
  113.    }
  114.  
  115. 3. The data should be free'd in the routine freegfc().
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.